<?php
function getPaperInfo($paper){
    global $db;
    $paperInfo = array();
    $sql = <<< EOT
        SELECT Name, Web
        FROM Newspapers
        WHERE ShortName LIKE '%s'
EOT;
    $sql = sprintf($sql, $db->escape($paper));
    $result = $db->query($sql);
    if ($db->rowCount($result) > 0) {
        $row = $db->fetch($result);
        if (!empty($row['Web']));
        $paperInfo = array("name" => $db->unescape($row['Name']), "url" => $db->unescape($row['Web']));
    }
    return $paperInfo;
}
function paperInfo($name) {
    $paperRegex = '/DEATH-NOTICE-(.*)-[0-9]*/';
    if (preg_match($paperRegex, $name)) {
        $name = preg_replace($paperRegex, '$1', $name);
    }
    $paperInfo = getPaperInfo($name);
    return $paperInfo;
}
?>